package com.xps.limedriver.view.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.jude.utils.JUtils;
import com.xps.limedriver.R;
import com.xps.limedriver.bean.LoginBean;
import com.xps.limedriver.date.net.UserNetWorks;
import com.xps.limedriver.view.base.BaseActivity;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import rx.Subscriber;

/**
 * Created by 吾丶说谎者 on 2017/12/7.
 */

public class LoginActivity extends BaseActivity {
    @Bind(R.id.Edit_Phone)
    EditText EditPhone;
    @Bind(R.id.Edit_Password)
    EditText EditPassword;
    @Bind(R.id.Button_Login)
    Button ButtonLogin;
    @Bind(R.id.Text_Forget)
    TextView TextForget;
    @Bind(R.id.Text_Register)
    TextView TextRegister;

    @Override
    protected int getLayout() {
        return R.layout.activity_login;
    }

    @Override
    protected void setData() {

    }

    @Override
    protected void init(Bundle inBundle) {
        ButterKnife.bind(this);
    }

    @OnClick({R.id.Button_Login, R.id.Text_Forget, R.id.Text_Register})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.Button_Login:
                startActivity(new Intent(LoginActivity.this, MainActivity.class));
                break;
            case R.id.Text_Forget:
                startActivity(new Intent(LoginActivity.this, ForgetActivity.class));
                break;
            case R.id.Text_Register:
                startActivity(new Intent(LoginActivity.this, RegisterActivity.class));
                break;
        }
    }

    public void NotInstalled() {
        UserNetWorks.UserLogin("liwenhan", "123456", new Subscriber<LoginBean>() {
            @Override
            public void onCompleted() {

            }

            @Override
            public void onError(Throwable e) {
                e.printStackTrace();
            }

            @Override
            public void onNext(LoginBean loginBean) {
                dissmisDialog();
                if (loginBean.getReturn_code().equals("FALL")) {
                    JUtils.Toast("登陆失败");
                } else {
                    JUtils.Toast("登陆成功");
                }
            }
        });
    }
}
